package malaria_acd;

import database.DatabaseAdapter;
import project.malaria.malaria_acd.R;
import project.malaria.malaria_acd.R.layout;
import project.malaria.malaria_acd.R.menu;
import android.os.Bundle;
import android.app.Activity;
import android.database.Cursor;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemSelectedListener;

public class SyncActivity extends Activity {
	private Spinner select_sync;
	private Cursor curProvince;
	private String search_id,search_id2,select_province,select_province_id;
	@Override
	protected void onCreate(  Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sync);
		select_sync = (Spinner) findViewById(R.id.spinner1);
		DatabaseAdapter db = new DatabaseAdapter(this);	
   	 db.openWriteDataBase();
			curProvince = db.getCursorProvince();
  
   	SimpleCursorAdapter adapter;
       adapter = new SimpleCursorAdapter(this, R.layout.layout_spinner_small, curProvince,new String[] {"PROVINCE_NAME_TH"},new int[] {android.R.id.text1});
       adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
       select_sync.setAdapter(adapter);
       select_sync.setOnItemSelectedListener(new OnItemSelectedListener() {
	
			@SuppressWarnings("unused")
			public void onItemSelected(AdapterView<?> paramAdapterView,
					View paramView, int paramInt, long paramLong) {
				// TODO Auto-generated method stub
				Object item = paramAdapterView.getItemAtPosition(paramInt);
				search_id = ""+paramLong;
				search_id2 = search_id;
				select_province ="";
   			if(curProvince.moveToPosition(paramInt)){
   				select_province = curProvince.getString(curProvince.getColumnIndex("PROVINCE_NAME_TH"));
   				select_province_id = curProvince.getString(curProvince.getColumnIndex("_id"));
  				
   			}			
			
			}

			public void onNothingSelected(AdapterView<?> paramAdapterView) {
				// TODO Auto-generated method stub
				
			}
   		
   		
		});	
   	db.close();
   	
	}

	 

}
